﻿set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go

-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	<Description,,>
-- =============================================
ALTER TRIGGER [TRI_AUTHOR] 
   ON [dbo].[BAS_AUTHOR]
   AFTER INSERT
AS 
DECLARE @NAME VARCHAR(200);
DECLARE @TOTAL BIGINT;
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- Int32erfering with SELECT statements.
	SET @NAME = (SELECT NAME FROM INSERTED);
	SET @TOTAL = (SELECT COUNT(*) FROM BAS_AUTHOR WHERE NAME=@NAME);
	UPDATE BAS_AUTHOR SET TOTALCOUNT=@TOTAL WHERE NAME=@NAME;
	SET NOCOUNT ON;

    -- Insert statements for trigger here

END